~ chicken-core (master) /manual/Module (scheme file)


 1[[tags: manual]]
 2[[toc:]]
 3
 4== Module (scheme file)
 5
 6<procedure>(call-with-input-file string proc)</procedure><br>
 7<procedure>(call-with-output-file string proc)</procedure>
 8
 9It is an error if proc does not accept one argument.
10
11These procedures obtain a textual port obtained by opening the named file for
12input or output as if by open-input-file or open-output-file. The port and
13proc are then passed to a procedure equivalent to call-with-port.
14
15<procedure>(with-input-from-file string thunk)</procedure><br>
16<procedure>(with-output-to-file string thunk)</procedure><br>
17
18The file is opened for input or output as if by open-input-file or 
19open-output-file, and the new port is made to be the value returned by 
20current-input-port or current-output-port (as used by {{(read)}}, {{(write obj)}}, and so forth). The
21thunk is then called with no arguments. When the
22thunk returns, the port is closed and the previous default is restored. It is
23an error if
24thunk does not accept zero arguments. Both procedures return the values yielded
25by
26thunk. If an escape procedure is used to escape from the continuation of these
27procedures, they behave exactly as if the current input or output port had been
28bound dynamically with parameterize.
29
30<procedure>(open-input-file string)</procedure><br>
31<procedure>(open-binary-input-file string)</procedure><br>
32
33Takes a
34string for an existing file and returns a textual input port or binary input
35port that is capable of delivering data from the file. If the file does not
36exist or cannot be opened, an error that satisfies file-error? is signaled.
37
38<procedure>(open-output-file string)</procedure><br>
39<procedure>(open-binary-output-file string)</procedure><br>
40
41Takes a
42string naming an output file to be created and returns a textual output port or
43binary output port that is capable of writing data to a new file by that name.
44If a file with the given name already exists, the effect is unspecified. If the
45file cannot be opened, an error that satisfies file-error? is signaled.
46
47<procedure>(file-exists? filename)</procedure><br>
48
49It is an error if
50filename is not a string.
51
52The file-exists? procedure returns #t if the named file exists at the time the
53procedure is called, and #f otherwise.
54
55<procedure>(delete-file filename)</procedure><br>
56
57It is an error if
58filename is not a string.
59
60The delete-file procedure deletes the named file if it exists and can be
61deleted, and returns an unspecified value. If the file does not exist or cannot
62be deleted, an error that satisfies file-error? is signaled.
63
64---
65Previous: [[Module (scheme complex)]]
66
67Next: [[Module (scheme
68 eval)]]
Trap